package com.dfl.gankio.net

import androidx.lifecycle.Observer


abstract class NetObserver<T> : Observer<BaseResult<T>> {

    override fun onChanged(result: BaseResult<T>?) {
        if (result != null && result.status == 100) {
            result.data?.let { onSuccess(it) }
        } else {
            onError("data is null")
        }
    }

    abstract fun onSuccess(data: T)

    abstract fun onError(emssage: String)
}